package com.nuonuo.es.utils;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * @author duan
 * @version 1.0
 * @date 2023/8/30 18:11
 */
public class ConvertUtils {
    public static Map<String, Object> object2Map(Object obj) {
        Map<String, Object> map = new HashMap(16);
        if (obj == null) {
            return map;
        } else {
            Class clazz = obj.getClass();
            Field[] fields = clazz.getDeclaredFields();

            try {
                Field[] var4 = fields;
                int var5 = fields.length;

                for(int var6 = 0; var6 < var5; ++var6) {
                    Field field = var4[var6];
                    field.setAccessible(true);
                    map.put(field.getName(), field.get(obj));
                }
            } catch (Exception var8) {
                var8.printStackTrace();
            }

            return map;
        }
    }

}
